package com.create.builder;

import java.util.ArrayList;
import java.util.List;

/**
 * 菜单
 *
 * @author xiaobing
 * @version 1.0
 * @date 2021/9/6 4:03 下午
 */
public class Meal {

    private List<Item> itemList = new ArrayList<>();
    /**
     * 套餐名称
     */
    private String mealName;

    /**
     * 添加商品
     *
     * @param item
     */
    public void addItem(Item item) {
        itemList.add(item);
    }

    /**
     * 套餐总额
     */
    public void getCost() {
        Float sum = 0f;
        for (Item item : itemList) {
            sum = sum + item.price();
        }
        System.out.println("此套餐为：" + mealName + ";总价格为：" + sum);
    }

    public void setMealName(String mealName) {
        this.mealName = mealName;
    }

    /**
     * 套餐展示
     */
    public void showItems() {
        for (Item item : itemList) {
            System.out.println("商品：" + item.name() + ";商品包装为：" + item.packing().pack() + ";商品价格为：" + item.price());
        }
    }

    public String getMealName() {
        return mealName;
    }
}
